﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Game
{
    public abstract class GameObjectCharacterInfo : GameObjectMoveableInfo
    {
    }


    /*-------------------------------------------------------------------------
    | Character:
    | ------------
    | Character
    |---------------------------------------------------------------------------*/
    public abstract class GameObjectCharacter : GameObjectMoveable
    {
        public class SkillsList : TypeList<Character.Skills.Skill>
        {
            public void Reset()
            {
                foreach (var it in this)
                {
                    it.Value.Value = it.Value.Max;
                }
            }
        }

        public TypeList<Character.States.State> States = new TypeList<Character.States.State>();
        public TypeList<Character.Abilities.Ability> Abilities = new TypeList<Character.Abilities.Ability>();

        public SkillsList Skills = new SkillsList();


        public override void Invalidate()
        {
            Body.SetPosition(Body.SceneNode.GetTransformation().GetWorldPosition() + Body.PivotPosition);
        }

        public virtual void DamageHit(GameObjectCharacter sender)
        {

        }

        public override void OnUpdate(Events.ProcessSceneUpdate evnt)
        {
            //update states
            foreach (var it in States)
            {
                if (it.Value.Enable)
                {
                    it.Value.Update(this, evnt);
                }
            }

            //update abilities
            foreach (var it in Abilities)
            {
                if (it.Value.Enable)
                {
                    it.Value.OnUpdate(this, evnt);
                }
            }

            base.OnUpdate(evnt);
        }
    }
}
